<div class="form">
    <?php /* @var $form CActiveForm */ ?>
    <?php
    /* @var $form CActiveForm */

    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'category-form',
        'enableAjaxValidation' => false,
        'enableClientValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true,
        ),
            ));
    ?>
    <p class="note">Trường nhập liệu với <span class="required">*</span> là bắt buộc.</p>
    <?php
    echo $form->errorSummary($category);
    echo $form->errorSummary($categoryDetails);
    ?>

    <table style="color:#555555; width: auto;">
        <tr>
            <td><?php echo $form->labelEx($category, 'Loại danh mục'); ?></td>
            <td>
                <?php
                echo $form->dropDownList($category, 'parent_id', CHtml::listData($categoryTypes, 'id', 'name')); // array('prompt' => 'Chọn loại danh mục')
                ?>
            </td>
            <td><?php echo $form->error($category, 'parent_id'); ?></td>
        </tr>
        <tr>
            <td><?php echo $form->label($category, 'hasParent'); ?></td>
            <td><?php echo $form->checkBox($category, 'hasParent'); ?></td>
            <td><?php echo $form->error($category, 'hasParent'); ?></td>
        </tr>
        <?php foreach ($categoryDetails as $i => $categoryDetail): ?>
            <tr>
                <td><?php echo $form->labelEx($categoryDetail, ($categoryDetail->language == 'vi' ? 'Tên' : 'Tên tiếng Anh') . ' (*)') ?></td>
                <td><?php echo $form->textField($categoryDetail, "[$i]name", array('size' => 40, 'title' => 'Đặt tên cho danh mục')) ?></td>
                <td> <?php echo $form->error($categoryDetail, "[$i]name"); ?></td>
            </tr>   
        <?php endforeach; ?>
        <tr>
            <td></td>
            <td>
                <div class="row submit">
                    <?php echo CHtml::submitButton($category->isNewRecord ? 'Create' : 'Save'); ?>
                </div>
            </td>
        </tr>
    </table>
    <?php $this->endWidget(); ?>
</div><!-- form -->